import Utils from '@/utils/index'
// #ifndef VUE3
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
const store = new Vuex.Store({
// #endif

// #ifdef VUE3
import { createStore } from 'vuex'
const store = createStore({
// #endif
	state: {
		$BASE_URL: 'http://localhost:8080',
		$utils: Utils,
		$pageSchema: [{
			id: "page1",
			text: '页面',
			pageSetup: { // 页面设置属性
				name: '页面标题', //页面名称
				details: '', //页面描述
				isPerson: false, // 是否显示个人中心
				isBack: true, // 是否返回按钮
				titleHeight: 35, // 高度
				bgColor: '#fff', //背景颜色
				bgImg: '', // 背景图片
			},
			pageComponents: [],
		}],

		$rightcom: 'decorate',
		$leftcom: 'assembly',


		$currentproperties: {}, // 选中组件的setStyle
		$currentComponent: {}, // 选中组件
		$curWidgetId: '' // 新建组件或选中组件的ID
	},
	mutations: {
		$setRightcom(state, newVal) {
			state.$rightcom = newVal
		},
		$setLeftcom(state, newVal) {
			state.$leftcom = newVal
		},
		$setCurrentproperties(state, newVal) {
			state.$currentproperties = newVal
		},
		// 新增组件,自动生成组件ID
		$setCurWidgetId(state, newVal) {

			state.$curWidgetId = newVal
		},
		$setCurrentComponent(state, newVal) {

			state.$currentComponent = newVal
		},
		$setPageSchema(state, newVal) {
			// console.info(newVal)
			state.$pageSchema = newVal
		},
		//清空页面
		$reload(state) {
			state.$pageSchema[0].pageComponents = [],
			state.$rightcom = 'decorate',
			state.$currentproperties = {}, // 选中组件的setStyle
			state.$currentComponent = {}, // 选中组件
			state.$curWidgetId = '' // 新建组件或选中组件的ID
		}

	},
	actions: {
		$reloadAsync(context) {
			context.commit('$reload')
		}
	},
	modules: {},
})
export default store